<template>
    <section>
        <!--工具条-->

        <div class="section-content clearfix">
            <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
                <el-form :inline="true" :model="filters" @submit.native.prevent>
                    <el-form-item style="float: left;">
                        <el-input v-model="filters.name" placeholder="模板名称" @keyup.enter.native="getUsers()"></el-input>
                    </el-form-item>
                    <el-form-item class="tool-bt">
                        <el-button :type="buttonColor" v-on:click="getUsers">查询</el-button>
                    </el-form-item>
                    <el-form-item v-if="menubt.indexOf('/device_template/post')>-1">
                        <el-button :type="buttonColor" @click="handleAdd">新增</el-button>
                    </el-form-item>
                </el-form>
            </el-col>

            <!--列表-->
            <el-table :data="query" highlight-current-row v-loading="listLoading" @selection-change="selsChange" :header-row-style="{backgroundColor: titleColor}" style="width: 100%;">
                <el-table-column type="selection" >
                </el-table-column>
                <el-table-column align="center" type="index" label="序号"  width="80" :index="indexMethod">
                </el-table-column>
                <el-table-column align="center" prop="name" label="模板名称">
                </el-table-column>
                <!-- <el-table-column prop="deviceUserId" label="设备标识">
                </el-table-column> -->
             
                <!-- <el-table-column prop="province" label="省">
                </el-table-column>
                <el-table-column prop="city" label="市">
                </el-table-column> -->
          
                <el-table-column align="center" prop="updateTime" label="更新时间">
                </el-table-column>
                <!-- <el-table-column align="center" prop="vendorUserId" label="组态" v-if="menubt.indexOf('/topo')>-1">
                    <template scope="scope">
                        <el-button   size="small" @click="handleEdit1(scope.$index, scope.row)" title="编辑" icon="el-icon-edit" circle></el-button>
                    </template>
                </el-table-column>
                <el-table-column v-if="menubt.indexOf('/template/app')>-1" align="center" label="UI模板">
                    <template scope="scope">
                        <span class="pb-name" @click="Registerset(scope.$index, scope.row)">{{scope.row.uiId!=0? scope.row.uiName:'未指定UI模板'}}</span>
                        <el-button v-if="scope.row.uiId" size="small" @click="getCheck(scope.$index, scope.row)">校验</el-button>
                    </template>
                </el-table-column> -->
                <el-table-column align="center" label="操作">
                    <template scope="scope">
                        <i v-if="menubt.indexOf('/device_template/put')>-1" @click="handleEdit(scope.$index, scope.row)" title="编辑" icon="el-icon-edit"
                            circle class="pb-icon icon-edit"></i>
                            <i v-if="menubt.indexOf('/device_template/delete')>-1" @click="handleDel(scope.$index, scope.row)" icon="el-icon-delete"
                            circle title="删除" class="pb-icon icon-delete"></i>
                        <!-- <el-button  v-if="menubt.indexOf('/device_template/put')>-1" size="small" @click="handleEdit(scope.$index, scope.row)" title="编辑" icon="el-icon-edit"
                            circle></el-button>
                        <el-button  v-if="menubt.indexOf('/device_template/delete')>-1" type="danger" size="small" @click="handleDel(scope.$index, scope.row)" icon="el-icon-delete"
                            circle title="删除"></el-button> -->
                        <i class="el-icon-download" style="font-size:30px;cursor:pointer;color:#0099cc;" title="模板下载" @click="tableToExcel(scope.$index,scope.row)"></i>
                        <i class="el-icon-document" style="font-size:30px;cursor:pointer;color:#0099cc;" title="复制设备模板" @click="handCopy(scope.$index,scope.row)"></i>
                    </template>
                </el-table-column>
            </el-table>

            <!--工具条-->
            <el-col :span="24" class="toolbar">
                <el-button  v-if="menubt.indexOf('/device_template/delete')>-1" type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>
                <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="10" :total="total"
                    style="float:right;">
                </el-pagination>
            </el-col>
        </div>
        <!--编辑界面-->
        <el-dialog title="编辑" v-show="editFormVisible" v-model="editFormVisible" :custom-class="dialogTitleColor" @close="editFormVisible=false">
            <div slot="footer" style="text-align: left; ">
                <el-form :model="editForm" label-width="110px" :rules="editFormRules" ref="editForm">
                    <el-form-item label="设备设备模板名称" prop="name" class="grade">
                        <el-input v-model="editForm.name" auto-complete="off"></el-input>
                    </el-form-item>

                    <el-form-item label="设备类型" class="grade">
                        <el-select v-model="editForm.deviceTypeId" placeholder="请选择设备类型">
                            <el-option v-for="item in typelist" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <!-- <el-form-item label="厂商用户" class="grade">
                        <el-input v-model="addForm.vendorUserId" auto-complete="off"></el-input>
                    </el-form-item> -->
                    <el-form-item label="设备所属用户" class="grade">
                        <el-input v-model="editForm.deviceUserId" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="移动属性" class="grade">
                            <el-radio-group v-model="editForm.moving">
                            <el-radio label="0">否</el-radio>
                            <el-radio label="1">是</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="订单号" class="grade">
                        <el-input v-model="editForm.orderSn" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="行业" prop="guild" class="grade">
                        <el-select v-model="editForm.guild" placeholder="请选择行业">
                            <el-option v-for="item in industrylist" :label="item.remark" :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="区域" class="grade">
                        <el-input v-model="editForm.area" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="是否默认">
                        <el-radio-group v-model="editForm.isDefault">
                            <el-radio label="0">否</el-radio>
                            <el-radio label="1">是</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="省" class="grade">
                        <el-input v-model="editForm.province" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="市" class="grade">
                        <el-input v-model="editForm.city" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="备注" prop="remark">
                        <el-input v-model="editForm.remark" auto-complete="off"></el-input>
                    </el-form-item>


                </el-form>
                <div slot="footer" class="dialog-footer" style="text-align:right;">
                    <el-button @click.native="editFormVisible = false">取消</el-button>
                    <el-button :type="buttonColor" @click.native="editSubmit" :loading="editLoading">提交</el-button>
                </div>
            </div>
        </el-dialog>

        <!--新增界面-->
        <el-dialog title="新增" v-show="addFormVisible" v-model="addFormVisible" :custom-class="dialogTitleColor" @close="addFormVisible=false">
            <div slot="footer" style="text-align: left; ">
                <el-form :model="addForm" label-width="110px" :rules="addFormRules" ref="addForm">
                    <el-form-item label="设备模板名称" prop="name" class="grade">
                        <el-input v-model="addForm.name" auto-complete="off"></el-input>
                    </el-form-item>

                    <el-form-item label="设备类型" class="grade">
                        <el-select v-model="addForm.deviceTypeId" placeholder="请选择设备类型">
                            <el-option v-for="item in typelist" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <!-- <el-form-item label="厂商用户" class="grade">
                        <el-input v-model="addForm.vendorUserId" auto-complete="off"></el-input>
                    </el-form-item> -->
                    <el-form-item label="设备所属用户" class="grade">
                        <el-input v-model="addForm.deviceUserId" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="移动属性" class="grade">
                            <el-radio-group v-model="addForm.moving">
                            <el-radio label="0">否</el-radio>
                            <el-radio label="1">是</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="订单号" class="grade">
                        <el-input v-model="addForm.orderSn" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="行业" prop="guild" class="grade">
                        <el-select v-model="addForm.guild" placeholder="请选择行业">
                            <el-option v-for="item in industrylist" :label="item.remark" :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="区域" class="grade">
                        <el-input v-model="addForm.area" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="是否默认">
                        <el-radio-group v-model="addForm.isDefault">
                            <el-radio label="0">否</el-radio>
                            <el-radio label="1">是</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="省" class="grade">
                        <el-input v-model="addForm.province" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="市" class="grade">
                        <el-input v-model="addForm.city" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="备注" prop="remark">
                        <el-input v-model="addForm.remark" auto-complete="off"></el-input>
                    </el-form-item>


                </el-form>
                <div slot="footer" class="dialog-footer" style="text-align: right;">
                    <el-button @click.native="addFormVisible = false">取消</el-button>
                    <el-button :type="buttonColor" @click.native="addSubmit" :loading="addLoading">提交</el-button>
                </div>
            </div>
        </el-dialog>
        <el-dialog title="编辑" v-show="copyVisible" v-model="copyVisible" :custom-class="dialogTitleColor" @close="copyVisible=false">
            <div slot="footer" style="text-align: left; ">
                <el-form :model="copyForm" label-width="120px" :rules="copyFormRules" ref="copyForm">
                    <el-form-item label="请输入新名称" prop="name">
                        <el-input v-model="copyForm.name" auto-complete="off"></el-input>
                    </el-form-item>

                </el-form>
                <div slot="footer" class="dialog-footer" style="text-align:right;">
                    <el-button @click.native="copyVisible = false">取消</el-button>
                    <el-button :type="buttonColor" @click.native="copySubmit" :loading="editLoading">提交</el-button>
                </div>
            </div>
        </el-dialog>
    </section>
</template>

<script>
    // import util from './../common/js/util'
    //import NProgress from 'nprogress'
    import {
        device_type_query,
        device_template_query,
        device_template_post,
        device_template_put,
        device_template_get,
        device_template_delete,
        dict_query,
        device_model_query,
        query_device_user,
        device_data_recipe_query,
        device_template_copy
    } from '../../api/api';

    export default {
        data() {
            return {
                typelist: '',
                modellist:'',//网关型号列表
                userlist:'',//所属用户列表
                device_data:'',//从机设备列表
                filters: {
                    name: ''
                },
                query: [],
                total: 0,
                page: 1,
                listLoading: false,
                copyVisible:false,
                sels: [], //列表选中列

                editFormVisible: false, //编辑界面是否显示
                editLoading: false,
                editFormRules: {
                    name: [{
                        required: true,
                        message: '请输入模板名称',
                        trigger: 'blur'
                    },{ min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }]
                },
                //编辑界面数据
                editForm: {
                    id: '',
                    name: '',
                    deviceTypeId: '',
                    vendorUserId: '',
                    deviceUserId: '',
                    moving: '',
                    orderSn: '',
                    guild: '',
                    area: '',
                    isDefault: '',
                    province: '',
                    city: '',
                    remark: ''
                },

                addFormVisible: false, //新增界面是否显示
                addLoading: false,
                addFormRules: {
                    name: [{
                        required: true,
                        message: '请输入模板名称',
                        trigger: 'blur'
                    },{ min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }],
                    path: [{
                            required: true,
                            message: '请输入path',
                            trigger: 'blur'
                        }

                    ]
                },
                copyFormRules:{
                    name: [{
                        required: true,
                        message: '请输入模板名',
                        trigger: 'blur'
                    },{ min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }]
                },
                copyForm:{
                    name:'',
                    id:'',
                },
                //新增界面数据
                addForm: {
                    name: '',
                    deviceTypeId: '',
                    vendorUserId: '0',
                    deviceUserId: '',
                    moving: '',
                    orderSn: '',
                    guild: '',
                    area: '',
                    isDefault: '0',
                    province: '',
                    city: '',
                    remark: ''
                },
                industrylist:''

            }
        },
        computed:{
            buttonColor(){
                return this.$store.state.buttonColor
            },
            titleColor(){
                return this.$store.state.titleColor
            },
            dialogTitleColor(){
                return this.$store.state.dialogTitleColor
            },
        },
        methods: {
            indexMethod(index) {
                let num = (this.page - 1) * 10 + index + 1;
                return num;
            },
            //性别显示转换
            formatSex: function (row, column) {
                return row.sex == 1 ? '男' : row.sex == 0 ? '女' : '未知';
            },
            handleCurrentChange(val) {
                this.page = val;
                this.getUsers();
            },
            //获取菜单列表
            getUsers() {
                if(this.menubt.indexOf('/device_template/query')==-1){  this.$message({
                            message: '您没有查询设备模板的权限',
                            type: 'warning'
                        });
                return false;
               }
                let para = {
                    pageNo: this.page,
                    pageSize: 10,
                    name: this.filters.name
                };
                this.listLoading = true;
                //NProgress.start();
                device_template_query(para).then((res) => {
                     this.begCode(res.code,res.message);
                    this.total = res.data.totalCount;
                    this.query = res.data.list;
                    this.page=res.data.pageNo;
                    this.listLoading = false;
                    //NProgress.done();
                });
            },
            //删除
            handleDel: function (index, row) {
                this.$confirm('确认删除该模板吗?', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    //NProgress.start();
                    let para = {
                        idList: [row.id]
                    };
                    device_template_delete(para).then((res) => {
                         this.begCode(res.code,res.message);
                        if (res.code == 0) {

                            this.listLoading = false;
                            //NProgress.done();
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            this.getUsers();

                        }
                    });
                }).catch(() => {

                });
            },
            //显示编辑界面
            handleEdit: function (index, row) {
                sessionStorage.setItem('deviceId', row.id);
                
                this.$router.push({
                    path: "/template/deviceedit"
                });
                return false;
            },
             handleEdit1: function (index, row) {
                 window.open("/configurat/spa/?name="+row.name+"&token="+JSON.parse(localStorage.getItem("key"))+"&id="+row.id,"_blank");  
                return false;
            },
            //复制数据配方的改名页面
            handCopy:function(index,row) {
                console.log(row)
                this.copyVisible = true
                this.copyForm.id = row.id              
            },
            //显示新增界面
            handleAdd: function () {
                this.$router.push({
                    path: '/template/deviceadd'
                })
            },
            //编辑
            editSubmit: function () {
                this.$refs.editForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            this.editLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.editForm);

                            device_template_put(para).then((res) => {
                                 this.begCode(res.code,res.message);

                                if (res.code == 0) {
                                    this.editLoading = false;
                                    //NProgress.done();
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
                                    this.$refs['editForm'].resetFields();
                                    this.editFormVisible = false;
                                    this.getUsers();
                                }
                            });
                        });
                    }
                });
            },
            //复制设备配方
            copySubmit(){
                this.$refs.copyForm.validate((valid) => {
                    if(valid){
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            this.editLoading = true;
                            let para = {
                                id: this.copyForm.id,
                                name: this.copyForm.name
                            }
                            console.log(para)
                            device_template_copy(para).then((res) => {
                                if(res.code ==0){
                                     this.editLoading = false;
                                     this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
                                     this.copyVisible = false
                                     this.$refs['copyForm'].resetFields();
                                     this.getUsers();
                                }
                            })
                        })
                    }
                })
            },
            //新增
            addSubmit: function () {
                this.$refs.addForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            this.addLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.addForm);

                            device_template_post(para).then((res) => {
                                 this.begCode(res.code,res.message);
                                this.addLoading = false;
                                //NProgress.done();
                                if(res.code==0){
                                    this.$message({
                                    message: '提交成功',
                                    type: 'success'
                                });
                                this.$refs['addForm'].resetFields();
                                this.addFormVisible = false;
                                this.getUsers();
                                }
                              
                            });
                        });
                    }
                });
            },
            selsChange: function (sels) {
                this.sels = sels;
            },
            //批量删除
            batchRemove: function () {
                var ids = this.sels.map(item => item.id).toString();
                this.$confirm('确认删除选中记录吗？', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    //NProgress.start();
                    let para = {
                        ids: ids.split(',')
                    };
                    device_template_delete(para).then((res) => {
                         this.begCode(res.code,res.message);
                        this.listLoading = false;
                        //NProgress.done();
                        this.$message({
                            message: '删除成功',
                            type: 'success'
                        });
                        this.getUsers();
                    });
                }).catch(() => {

                });
            },
            Registerset(index,row){
                if(row.uiId==0 || row.uiId==null){
                    this.$message({
                            message: '请先绑定UI模板',
                            type: 'warning'
                        });
                    return false
                }else{
                    this.$router.push('/template/app')
                    sessionStorage.setItem("devicetemplateuiId",row.uiId)
                    sessionStorage.setItem("deviceCompanyId",row.companyId)
                    sessionStorage.setItem("deviceTemplateName",row.name +'/'+ row.uiName)
                }
            },
            tableToExcel(index,row){
                // console.log(row)
                var jsonData = [
                    {
                    name:'',//配方名字
                    // terminalUserName:'',//终端用户
                    deviceTypeId:'',//设备类型
                    deviceModelId:'',//网关型号
                    deviceUserId:'',//设备所属用户
                    moving:'',//移动属性
                    orderSn:'',//订单号
                    guild:'',//行业
                    area:'',//排序值
                    remark:'',//备注
                    address:'',//地址
                    // deviceSlaveList:[]//从机
                }];
                var slaveList = []

                let para = {
                    id:row.id
                }
                device_template_get(para).then((res) => {
                    console.log(res)
                    jsonData[0].name = res.data.name//配方名字
                    // jsonData[0].terminalUserName = res.data.terminalUserName//终端用户
                    jsonData[0].remark = res.data.remark
                    jsonData[0].address = res.data.deviceLocation.address

                    let deviceType = this.typelist.find((item) => {
                        return item.id = res.data.deviceTypeId
                    })
                    jsonData[0].deviceTypeId = deviceType.name//设备类型

                    let deviceMode = this.modellist.find((item) => {
                        return item.id = res.data.deviceModelId
                    })
                    jsonData[0].deviceModelId = deviceMode.name//网关型号

                    let deviceUser = this.userlist.find((item) => {
                        return item.id = res.data.deviceUserId
                    })
                    jsonData[0].deviceUserId = deviceUser.name//设备所属用户
                    if(res.data.moving == 0){
                        jsonData[0].moving = "静止"
                    }else{
                        jsonData[0].moving = "移动"
                    }               
                    jsonData[0].orderSn = res.data.orderSn

                    let industry = this.industrylist.find((item) => {
                        return item.id = res.data.guild
                    })
                    jsonData[0].guild = industry.value//行业
                    jsonData[0].area = res.data.area

                    let slaveList = []
                    for(let i in res.data.deviceSlaveList){
                        slaveList[i] = {
                            priority:res.data.deviceSlaveList[i].priority,//排序值
                            name:res.data.deviceSlaveList[i].name,//从机名称
                            slaveSn:res.data.deviceSlaveList[i].slaveSn,//从机编号
                            deviceDataRecipeName:res.data.deviceSlaveList[i].deviceDataRecipeName//数据配方  
                        }
                    }
                    // jsonData[0].deviceSlaveList = slaveList
                    // console.log(jsonData)
                    // console.log(slaveList)
                    // console.log(this.industrylist)

                    //列标题，逗号隔开，每一个逗号就是隔开一个单元格
                    // let str = `设备模板名称,终端用户,设备类型,网关型号,设备所属用户,移动属性,订单号,行业,排序值,备注,地址\n`;
                    let str = `设备模板名称,设备类型,网关型号,设备所属用户,移动属性,订单号,行业,排序值,备注,地址\n`;
                    //增加\t为了不让表格显示科学计数法或者其他格式
                    for(let i = 0 ; i < jsonData.length ; i++ ){
                        for(let item in jsonData[i]){
                            str+=`${jsonData[i][item] + '\t'},`;     
                        }
                        str+='\n';
                    }
                    str +=`\n设备从机\n`
                    str += `排序值，从机名称，从机编号，数据模板\n`
                    for(let k = 0 ; k < slaveList.length ; k++ ){
                        for(let item in slaveList[k]){
                            str+=`${slaveList[k][item] + '\t'},`;     
                        }
                        str+='\n';
                    }
                    //encodeURIComponent解决中文乱码
                    let uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str);
                    //通过创建a标签实现
                    let link = document.createElement("a");
                    link.href = uri;
                    //对下载的文件命名
                    link.download =  res.data.name + ".csv";
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);

                    //  var str =
                    // '<tr><td>设备配方名称</td><td>终端用户</td><td>设备类型</td><td>网关型号</td><td>设备所属用户</td><td>移动属性</td><td>订单号</td><td>行业</td><td>排序值</td><td>备注</td><td>地址</td></tr>'
                     
                    // //Worksheet名
                    // for (let i = 0; i < jsonData.length; i++) {
                    //     str += '<tr>';
                    //     for (let item in jsonData[i]) {
                    //         //增加\t为了不让表格显示科学计数法或者其他格式
                    //         str += `<td>${ jsonData[i][item] + '\t'}</td>`;
                    //     }
                    //     str += '</tr>';
                    // }
                    // var worksheet = 'Sheet1'
                    // var uri = 'data:application/vnd.ms-excel;base64,';
                    // //下载的表格模板数据
                    // var template =
                    // `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">     
                    // <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                    // <head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
                    // <x:Name>${worksheet}</x:Name>
                    // <x:Name>${worksheet}</x:Name>
                    // <x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>
                    // </x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
                    // </head><body><table>${str}</table></body></html>`;
                    // //下载模板
                    // window.location.href = uri + this.base64(template)
                })
                             
            },//导出模板
             base64(s) {
                return window.btoa(unescape(encodeURIComponent(s)))
            },
            getCheck(index,row){
                console.log(row)
                this.$router.push('/template/uicmdCheck')
                sessionStorage.setItem("TemplateId",row.id)
            }
        },
        mounted() {
            this.menubt=localStorage.getItem('menubt');
            this.getUsers();
            let para = {
                pageNo: 1,
                pageSize: 1000

            }

            device_type_query(para).then((res) => {
                 this.begCode(res.code,res.message);

                this.addLoading = false;
                if (res.code == 0) {
                    this.typelist = res.data.list;
                } else {
                    this.$message({
                        message: res.message,
                        type: 'warning'
                    });
                }

            });
            let para1 = {
                name: 'industry',
                pageSize: 999,
                pageNo: 1,
            }
            dict_query(para1).then((res) => {
                 this.begCode(res.code,res.message);
                if (res.code == 0) {
                    this.addLoading = false;

                    this.industrylist = res.data.list;


                }

            });

            device_model_query(para).then((res) => {
                this.begCode(res.code,res.message);
                this.addLoading = false;
                if (res.code == 0) {
                    this.modellist = res.data.list;
                } else {
                    this.$message({
                        message: res.message,
                        type: 'warning'
                    });
                }

            });
            query_device_user(para).then((res) => {
                    this.begCode(res.code,res.message);
                    this.addLoading = false;
                    if (res.code == 0) {
                        this.userlist = res.data.list;
                    } else {
                        this.$message({
                            message: res.message,
                            type: 'warning'
                        });
                    }
                    });
            device_data_recipe_query(para).then((res) => {
                 this.begCode(res.code,res.message);
                if (res.code == 0) {
                    this.device_data = res.data.list;
                }
                this.listLoading = false;
                //NProgress.done();
            });
        }
    }
</script>

<style scoped>

</style>